package cn.kgc.service.impl;

import cn.kgc.mapper.UserMapper;
import cn.kgc.pojo.SmbmsUser;
import cn.kgc.service.UserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service("userService")
public class UserServiceimpl implements UserService {
    @Resource
    private UserMapper userMapper;

    @Override
    public SmbmsUser getdenglu(String userCode, String userPassword) {
        return userMapper.getdenglu(userCode,userPassword);
    }

    @Override
    public int getConut(String userName,Integer userRole) {
        return userMapper.getConut(userName,userRole);
    }

    @Override
    public List<SmbmsUser> getByPage(String userName,Integer userRole ,Integer currentPageNo, Integer pageSize) {
        Integer pageNow = (currentPageNo-1)*pageSize;
        return userMapper.getByPage(pageNow,pageSize,userName,userRole);
    }

    @Override
    public boolean addUser(SmbmsUser smbmsUser) {
        int conut = userMapper.addUser(smbmsUser);
        if (conut>0){
            return true;
        }else {
            return false;
        }
    }

    @Override
    public SmbmsUser getId(Integer id) {
        return userMapper.getId(id);
    }

    @Override
    public boolean updateUser(SmbmsUser smbmsUser) {
        int conut = userMapper.updateUser(smbmsUser);
        if (conut>0){
            return true;
        }else {
            return false;
        }
    }

    @Override
    public boolean delId(Integer id) {
        int conut = userMapper.delId(id);
        if (conut>0){
            return true;
        }else {
            return false;
        }
    }

    @Override
    public SmbmsUser getUserCode(String userCode) {
        return userMapper.getUserCode(userCode);
    }

}
